package com.gongj.shej.代理模式;

import com.sun.org.apache.bcel.internal.generic.NEW;

/**
 * @program: shej
 * @description: 真实对象和代理对象都要实现同一个接口   代理对象要代理真实对象(静态代理)
 * @author: gongj
 * @Description: TODO
 * @create: 2020-07-23 11:12
 **/
//结婚
public interface Marry {
    void happrMarry();

    public static void main(String[] args) {
        Me me = new Me();
        WeddingCompanyProxy proxy = new WeddingCompanyProxy(me);
        proxy.happrMarry();
    }
}

//我
class Me implements Marry{

    @Override
    public void happrMarry() {
        System.out.println("我要结婚啦，好开心阿");
    }
}

//婚庆公司
class WeddingCompanyProxy implements Marry{
    // 内部一定要有一个真实的实现类，当然也可以通过构造方法注入
    private Marry target;
    public WeddingCompanyProxy(Marry target) {
        this.target = target;
    }
    @Override
    public void happrMarry() {
        System.out.println("婚庆公司布置结婚现场");
        target.happrMarry();
        System.out.println("婚庆公司打扫结婚现场");
    }
}